import { ApiProperty,getSchemaPath,ApiExtraModel } from '@midwayjs/swagger';
import { Rule, RuleType } from '@midwayjs/validate';
import { ApiRes } from '.';

export class RepairItemId {
  @ApiProperty({ description: '报修项id', required: true })
  @Rule(RuleType.number().required().error(new Error('id不能为空')))
  id: number;
}

export class RepairItemName {
  @ApiProperty({ description: '报修项名称', required: true })
  @Rule(RuleType.string().required().error(new Error('名称不能为空')))
  name: string;
}

export class RepairItem {
  @ApiProperty({ description: '报修项id', required: true })
  @Rule(RuleType.number().required().error(new Error('id不能为空')))
  id: number;
  @ApiProperty({ description: '报修项名称', required: true })
  @Rule(RuleType.string().required().error(new Error('报修项名称不能为空')))
  name: string;
}

@ApiExtraModel(RepairItem)
export class RepairItemRes {
  @ApiProperty({
    type: 'array',
    items: {
      $ref: getSchemaPath(RepairItem),
    }
  })
  list: RepairItem[];
}
export class RepairItemResDto extends ApiRes<RepairItemRes>(
  RepairItemRes
) {}
